/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package py.com.peluq.model.entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Diego_M
 */
@Entity
@Table(name = "ajuste", catalog = "peludb", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Ajuste.findAll", query = "SELECT a FROM Ajuste a"),
    @NamedQuery(name = "Ajuste.findByIdajuste", query = "SELECT a FROM Ajuste a WHERE a.idajuste = :idajuste"),
    @NamedQuery(name = "Ajuste.findByFecha", query = "SELECT a FROM Ajuste a WHERE a.fecha = :fecha"),
    @NamedQuery(name = "Ajuste.findByEstado", query = "SELECT a FROM Ajuste a WHERE a.estado = :estado")})
public class Ajuste implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "idajuste", nullable = false)
    private Integer idajuste;
    @Column(name = "fecha")
    private Integer fecha;
    @Column(name = "estado")
    private Integer estado;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "ajuste1")
    private Collection<AjusteDet> ajusteDetCollection;
    @JoinColumns({
        @JoinColumn(name = "ddeposito", referencedColumnName = "iddeposito", nullable = false),
        @JoinColumn(name = "idseccion", referencedColumnName = "idseccion", nullable = false),
        @JoinColumn(name = "stock_idsucursal", referencedColumnName = "idsucursal", nullable = false),
        @JoinColumn(name = "prod_cod", referencedColumnName = "prod_cod", nullable = false)})
    @ManyToOne(optional = false)
    private Stock stock;

    public Ajuste() {
    }

    public Ajuste(Integer idajuste) {
        this.idajuste = idajuste;
    }

    public Integer getIdajuste() {
        return idajuste;
    }

    public void setIdajuste(Integer idajuste) {
        this.idajuste = idajuste;
    }

    public Integer getFecha() {
        return fecha;
    }

    public void setFecha(Integer fecha) {
        this.fecha = fecha;
    }

    public Integer getEstado() {
        return estado;
    }

    public void setEstado(Integer estado) {
        this.estado = estado;
    }

    @XmlTransient
    public Collection<AjusteDet> getAjusteDetCollection() {
        return ajusteDetCollection;
    }

    public void setAjusteDetCollection(Collection<AjusteDet> ajusteDetCollection) {
        this.ajusteDetCollection = ajusteDetCollection;
    }

    public Stock getStock() {
        return stock;
    }

    public void setStock(Stock stock) {
        this.stock = stock;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idajuste != null ? idajuste.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Ajuste)) {
            return false;
        }
        Ajuste other = (Ajuste) object;
        if ((this.idajuste == null && other.idajuste != null) || (this.idajuste != null && !this.idajuste.equals(other.idajuste))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "py.com.peluq.model.entity.Ajuste[ idajuste=" + idajuste + " ]";
    }
    
}
